﻿using System;
using System.Drawing;
using System.IO;
using System.Web.Mvc;
using AwesomeSlider.Extensions;
using AwesomeSlider.Models;
using AwesomeSlider.Services;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.Localization;

namespace AwesomeSlider.Drivers
{
    public class SliderItemPartDriver: ContentPartDriver<SliderItemPart>
    {
        private readonly IMediaExtendedService _mediaService;

        public SliderItemPartDriver(IMediaExtendedService mediaService)
        {
            _mediaService = mediaService;
            T = NullLocalizer.Instance;
        }

        public Localizer T { get; set; }

        protected override DriverResult Display(SliderItemPart part, string displayType, dynamic shapeHelper)
        {
            return displayType == "Summary"
                ? ContentShape("Parts_Sliders_SliderItem_Summary", () => shapeHelper.Parts_Sliders_SliderItem_Summary(Name: part.Name, Part: part))
                : ContentShape("Parts_Sliders_SliderItem", () => shapeHelper.Parts_Sliders_SliderItem(Name: part.Name, Part: part));
        }

        //GET
        protected override DriverResult Editor(SliderItemPart part, dynamic shapeHelper)
        {
            return ContentShape("Parts_Sliders_SliderItem_Edit",
                () => shapeHelper.EditorTemplate(
                    TemplateName: "Parts.Sliders.SliderItem",
                    Model: part,
                    Prefix: Prefix));
        }

        //POST
        protected override DriverResult Editor(SliderItemPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            return Editor(part, shapeHelper);
        }
    }
}